import cv2
import numpy as np
import matplotlib.pyplot as plt
img = cv2.imread("../images/test_wrap.png")
h,w,_ = img.shape
cv2.imshow("original image",img)
#获取透视矩阵
src = np.array([
    [75,232],
    [359,112],
    [473,255],
    [187,433]

],dtype="f4")
dst = np.array([
    [75,112],
    [473,112],
    [473,433],
    [75,433] ],dtype="f4")
M = cv2.getPerspectiveTransform(src,dst)
#透视变换
per_img = cv2.warpPerspective(
    img,
    M,
    (h,w)
)
cv2.imshow("per_img",per_img)
cv2.waitKey(0)